package com.cloudcross.ssp.model;

import java.util.Date;

import com.cloudcross.ssp.web.widget.SelectorController.ISelector;

/**
 * 订单表
 * <p/>
 * 与t_order表相关。
 */
public class Order implements ISelector {
    // 主键
    private Long    id;
    private Long    agentId;
    // 广告主ID
    private Long    advertiserId;
    //运营商id
    private Long    operatorId;
    // 订单名称
    private String  name;
    //购买类型（1公开交易，适用于DSP购买方式；2优先交易，适用于PDB/PD购买方式）
    private String  buyType;
    //设备类型(1PC广告，2WAP广告，3APP广告)
    private String  deviceType;
    //订单开始日期 格式：YYYY-MM-DD
    private String  dateStart;
    //订单结束日期 格式：YYYY-MM-DD
    private String  dateEnd;
    // 订单预算
    private Integer budget;
    //订单日预算 单位：元(默认0即不限)
    private Integer budgetDaily;
    //投放速度（1标准，均匀投放；2快速，在合理范围内尽快展示广告；3不限制，仅适合优先交易形式，PDB/PD）
    private String  speedMode;
    //利润率
    private Integer profit;
    //订单账期
    private String  orderaccountdate;
    // 更新日期
    private Date    updated;
    // 订单备注
    private String  comment;
    // 状态（0开启，1暂停）
    private Integer status;
    //单人点击频次类型
    private Integer perClickType;
    //单人点击频次
    private Long    perClick;

    //单人曝光频次类型
    private Integer perImpressionType;
    //单人曝光频次
    private Long    perImpression;
    //每个ip每天曝光次数
    private Integer perIpDayShow;

    private String  adgroupIds;       //策略ID的集合

    private Integer ownerId;          //订单所属人

    private String  ownerName;        //所属人名称

    public String getAdgroupIds() {
        return adgroupIds;
    }

    public void setAdgroupIds(String adgroupIds) {
        this.adgroupIds = adgroupIds;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getAgentId() {
        return agentId;
    }

    public void setAgentId(Long agentId) {
        this.agentId = agentId;
    }

    public Long getAdvertiserId() {
        return advertiserId;
    }

    public void setAdvertiserId(Long advertiserId) {
        this.advertiserId = advertiserId;
    }

    public Long getOperatorId() {
        return operatorId;
    }

    public void setOperatorId(Long operatorId) {
        this.operatorId = operatorId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getBuyType() {
        return buyType;
    }

    public void setBuyType(String buyType) {
        this.buyType = buyType;
    }

    public String getDeviceType() {
        return deviceType;
    }

    public void setDeviceType(String deviceType) {
        this.deviceType = deviceType;
    }

    public String getDateStart() {
        return dateStart;
    }

    public void setDateStart(String dateStart) {
        this.dateStart = dateStart;
    }

    public String getDateEnd() {
        return dateEnd;
    }

    public void setDateEnd(String dateEnd) {
        this.dateEnd = dateEnd;
    }

    public Integer getBudget() {
		return budget;
	}

	public void setBudget(Integer budget) {
		this.budget = budget;
	}

	public Integer getBudgetDaily() {
        return budgetDaily;
    }

    public void setBudgetDaily(Integer budgetDaily) {
        this.budgetDaily = budgetDaily;
    }

    public String getSpeedMode() {
        return speedMode;
    }

    public void setSpeedMode(String speedMode) {
        this.speedMode = speedMode;
    }

    public Integer getProfit() {
        return profit;
    }

    public void setProfit(Integer profit) {
        this.profit = profit;
    }

    public String getOrderaccountdate() {
        return orderaccountdate;
    }

    public void setOrderaccountdate(String orderaccountdate) {
        this.orderaccountdate = orderaccountdate;
    }

    public Date getUpdated() {
        return updated;
    }

    public void setUpdated(Date updated) {
        this.updated = updated;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getPerClickType() {
        return perClickType;
    }

    public void setPerClickType(Integer perClickType) {
        this.perClickType = perClickType;
    }

    public Long getPerClick() {
        return perClick;
    }

    public void setPerClick(Long perClick) {
        this.perClick = perClick;
    }

    public Integer getPerImpressionType() {
        return perImpressionType;
    }

    public void setPerImpressionType(Integer perImpressionType) {
        this.perImpressionType = perImpressionType;
    }

    public Long getPerImpression() {
        return perImpression;
    }

    public void setPerImpression(Long perImpression) {
        this.perImpression = perImpression;
    }

    public Integer getPerIpDayShow() {
        return perIpDayShow;
    }

    public void setPerIpDayShow(Integer perIpDayShow) {
        this.perIpDayShow = perIpDayShow;
    }

    public Integer getOwnerId() {
        return ownerId;
    }

    public void setOwnerId(Integer ownerId) {
        this.ownerId = ownerId;
    }

    public String getOwnerName() {
        return ownerName;
    }

    public void setOwnerName(String ownerName) {
        this.ownerName = ownerName;
    }



    @Override
    public String getLabel() {
        return this.name;
    }

    @Override
    public String getValue() {
        return String.valueOf(this.id);
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((advertiserId == null) ? 0 : advertiserId.hashCode());
        result = prime * result + Float.floatToIntBits(budget);
        result = prime * result + ((comment == null) ? 0 : comment.hashCode());
        result = prime * result + ((name == null) ? 0 : name.hashCode());
        return result;
    }

    @Override
    public String toString() {
        return "Order{" +
                "id=" + id +
                ", agentId=" + agentId +
                ", advertiserId=" + advertiserId +
                ", operatorId=" + operatorId +
                ", name='" + name + '\'' +
                ", buyType='" + buyType + '\'' +
                ", deviceType='" + deviceType + '\'' +
                ", dateStart='" + dateStart + '\'' +
                ", dateEnd='" + dateEnd + '\'' +
                ", budget=" + budget +
                ", budgetDaily=" + budgetDaily +
                ", speedMode='" + speedMode + '\'' +
                ", profit=" + profit +
                ", orderaccountdate='" + orderaccountdate + '\'' +
                ", updated=" + updated +
                ", comment='" + comment + '\'' +
                ", status=" + status +
                ", perClickType=" + perClickType +
                ", perClick=" + perClick +
                ", perImpressionType=" + perImpressionType +
                ", perImpression=" + perImpression +
                ", perIpDayShow=" + perIpDayShow +
                ", adgroupIds='" + adgroupIds + '\'' +
                ", ownerId=" + ownerId +
                ", ownerName='" + ownerName + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Order other = (Order) obj;
        if (advertiserId == null) {
            if (other.advertiserId != null)
                return false;
        } else if (!advertiserId.equals(other.advertiserId))
            return false;
        if (Float.floatToIntBits(budget) != Float.floatToIntBits(other.budget))
            return false;
        if (comment == null) {
            if (other.comment != null)
                return false;
        } else if (!comment.equals(other.comment))
            return false;
        if (name == null) {
            if (other.name != null)
                return false;
        } else if (!name.equals(other.name))
            return false;
        return true;
    }

    public String getStatusStr(int status) {
        if (status == 0) {
            return "开启";
        } else if (status == 1) {
            return "停用";
        } else {
            return status + "";
        }
    }
}
